package sctu.edu.java.year2016.team01.xuhanmei.day20160602.LearnException;

import java.io.*;

/**
 * Created by Administrator on 2016/6/2.
 */
public class CanWriteFile {
    public static void main(String[] args) {

        File f=new File("d:/test.txt");


        try {
            f.createNewFile();
            DataOutputStream fdata=new DataOutputStream(new FileOutputStream(f));
            fdata.writeChars("hjfdh");//相当于fdata.write("fhjfdh".getbytes());
            fdata.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
        if(f.exists()){
            f.delete();
            System.out.println("文件已删除！");
        }
        else{
            System.out.println("文件不存在");
        }
    }
}
